package com.bdqn.design.computer;

import java.util.Scanner;

/**
 * Test01SimpleComputerFactory
 *
 * @author LILIBO
 * @since 2024/7/4
 */
public class TestSimpleComputerFactory {

    private static final Scanner input = new Scanner(System.in);


    /**
     * 程序入口（终端）
     *
     * @param args
     */
    public static void main(String[] args) {
        System.out.print("请输入第一个数：");
        double num1 = input.nextDouble();
        System.out.print("请输入第二个数：");
        double num2 = input.nextDouble();
        System.out.print("请输入运算符：");
        String op = input.next();
        // 使用简单工厂根据运算符获取计算实例对象进行计算
        Computer computer = SimpleComputerFactory.getInstance(op);
        // 计算
        double result = computer.calculate(num1, num2);
        System.out.println("计算结果为：" + result);
    }

}
